<?php
/**
 *
 * @package    gadgets
 * @author     Daniel Botelho <botelho.daniel@gmail.com>
 */
class GadgetsPrefs
{
  private $var_name;
  /**
   */
  public function __construct($var_name)
  {
  	OSConfig::importSetPrefs();
    $this->var_name = $var_name;
  }
  
  public function initialize(){
  	return $this->__toString();
  }
  
  public function __toString(){
  	return 'var '.$this->var_name." = new gadgets.Prefs();\n";
  }
  
  public function getVarName(){ return $this->var_name; }
  
  /**
   *  Retrieves an array preference.
   */
  public function getArray($key,$appendable){ 
  	
  	return StringUtil::appendableString($this->getVarName().".getArray($key)",$appendable);
  } 
  
  /**
  *  Retrieves a boolean preference. Boolean getBool(key)
  */
  public function getBool($key,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getBool($key)",$appendable);
  }
   
  /**
   * Gets the current country, returned as ISO 3166-1 alpha-2 code. 
   */
  public function getCountry($appendable){
  	return StringUtil::appendableString($this->getVarName().".getCountry()",$appendable);
  }
  /**
   * Retrieves a floating-point preference. 
   */
  public function getFloat($key,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getFloat($key)",$appendable);
  }
  
  /**
   * Retrieves an integer preference. 
   */
  public function getInt($key,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getFloat($key)",$appendable);
  }
    
  /**
   * Gets the current language the gadget should use when rendering, returned as a ISO 639-1 language code. 
   */
  public function getLang($appendable){
  	return StringUtil::appendableString($this->getVarName().".getLang()",$appendable);
  }
   
  /**
   * Gets the module id for the current instance. 
   */
  public function getModuleId($appendable){
  	return StringUtil::appendableString($this->getVarName().".getModuleId()",$appendable);
  }

  /**
   * Fetches an unformatted message.
   */
  public function getMsg($key,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getMsg($key)",$appendable);
  }
     
  /**
   * Returns a message value with the positional argument opt_subst in place if it is provided or the provided example value if it is not, or the empty  public function  if the message is not found. 
   */
  public function getMsgFormatted($key, $opt_subst,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getMsgFormatted($key,$opt_subst)",$appendable);
  }
    
  /**
   * Retrieves a  public function  preference. 
   */
  public function getString($key,$appendable){
  	return StringUtil::appendableString($this->getVarName().".getString($key)",$appendable);
  }
    
  /**
   * Stores a preference. 
   */
  public function set($key, $val,$appendable){
  	return StringUtil::appendableString($this->getVarName().".set($key,$val)",$appendable);
  }
    
  /**
   * Stores an array preference.
   */
  public function setArray($key, $val,$appendable){
  	return StringUtil::appendableString($this->getVarName().".setArray($key,$val)",$appendable);
  }
}